
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>arguments对象</title>
</head>
<body>
    
    <script>
        // arguments对象:  arguments是函数内部内置的对象(伪数组),调用函数时来接受传入的所有实参


        // function add(a,b,c,d) {
        //     return  a+b+c+d;
        // }

        // console.log(add(1,2,3,4));



        function add() {
            console.log(arguments);
            
            let sum = 0;
            for (let i = 0; i < arguments.length; i++) {
               console.log(arguments[i]);
               sum = sum+= arguments[i]
            }
            return sum
        }

        console.log(add(1,2,3,4,5,6,7,8,9,10));


        

    </script>
</body>
</html>